<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
</head>
<body>
<p><strong>Ajax grabbed plain text:</strong></p>
<div id = "generated_content">&nbsp;</div>
<script>
	var xhr = new XMLHttpRequest();
	//指定请𣷌的属性
	xhr.open('GET', 'animal.xml', true);

	//定义回调函数
	xhr.onreadystatechange = function () {
		if(xhr.readyState == 4) {
			var message = '';
			if(xhr.status == 200) {

				message = '<pre>' + xhr.responseText + '</pre>';

				///** 对于XML文件，也可以像下面这样抓取XML并解析特殊的值
				var xml_data = xhr.responseXML;
				var names = xml_data.getElementsByTagName('name');

				for(var i = 0; i<names.length; i++) {
					message += names[i].firstChild.nodeValue + '<br />\n';
				}

			} else {
				message = 'An error has occoured making the request!';
			}

			document.getElementById('generated_content').innerHTML = message;
		}

	};

	xhr.send(null);
</script>
</body>
</html>